/**
 * related to main.ui
 * 
 * @Author : andywang
 * @Timestamp : 2016-06-26
 */
var page = sm("do_Page");
var app = sm("do_App");
var userUtil = require("helper/user");
var openHelper = require("helper/open");
var hashdata = mm("do_HashData");
var homemakingUtil = require("url/homemaking");
var qqHttp = require("helper/http");
var nf = sm("do_Notification");

//andriod返回键
page.on("back", function() {
    app.closePage();
});

/* 头部 */
var headerAout = ui("do_ALayout_header");
var addheader = headerAout.add("header", "source://view/reuse/header.ui", 0, 0);
//左上角-返回
var headerLeft = ui(addheader+".headerLeft");
headerLeft.on("touch", function() {
    app.closePage();
});

var header = ui("header");
header.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "我的服务"
})
header.refreshData();

var linearLayout_main = ui("linearLayout_main");

var aLayout_dsdsadd = linearLayout_main.add("aLayout_dsds", "source://view/reuse/form/mutiLabel.ui",0,0);
var aLayout_dsds = ui("aLayout_dsds");
aLayout_dsds.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "我的代收代送",
    "labelText":'',
    "labelTipsVisible":true
});
aLayout_dsds.refreshData();
aLayout_dsds.on("touch",function(){
	openHelper.open("source://view/order/list.ui",{orderType:5});
});

var aLayout_yuyue2add = linearLayout_main.add("aLayout_yuyue2", "source://view/reuse/form/mutiLabel.ui",0,0);
var aLayout_yuyue2 = ui("aLayout_yuyue2");
aLayout_yuyue2.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "我的预约（买家）",
    "labelTitleWidth":240,
    "labelText":'',
    "labelTipsVisible":true
});
aLayout_yuyue2.refreshData();
aLayout_yuyue2.on("touch",function(){
	var userId = userUtil.userId();
	if(userId && userId.trim()!=""){
		openHelper.open("source://view/order/list.ui",{orderType:1});
	}
})
var aLayout_yuyue1add = linearLayout_main.add("aLayout_yuyue1", "source://view/reuse/form/mutiLabel.ui",0,0);
var aLayout_yuyue1 = ui("aLayout_yuyue1");
aLayout_yuyue1.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "我的预约（卖家）",
    "labelTitleWidth":240,
    "labelText":'',
    "labelTipsVisible":true
});
aLayout_yuyue1.refreshData();
aLayout_yuyue1.on("touch",function(){
	var userId = userUtil.userId();
	if(userId && userId.trim()!=""){
		openHelper.open("source://view/homemaking/order/sellerList.ui");
	}
})

var aLayout_jinengadd = linearLayout_main.add("aLayout_jineng", "source://view/reuse/form/mutiLabel.ui",0,0);
var aLayout_jineng = ui("aLayout_jineng");
aLayout_jineng.bindData(hashdata);
hashdata.addData({
    "labelTitle" : "我的技能",
    "labelText":'',
    "labelTipsVisible":true
});
aLayout_jineng.refreshData();
aLayout_jineng.on("touch",function(){
	openHelper.open("source://view/homemaking/manage/myList.ui");
})

//页面装载完成后，开始初始化工作
page.on("loaded", function(){
	qqHttp.post(homemakingUtil.url.base.getCount, {}, function(data) {
		ui(aLayout_dsdsadd+".labelTips").text = data.deliveryOrderCount+"个订单等待签收";
		ui(aLayout_yuyue2add+".labelTips").text = data.waitReceiptCount+"个订单已服务，等待确认";
		ui(aLayout_yuyue1add+".labelTips").text = data.waitSendCount+"个订单已付款，等待上门";
		ui(aLayout_jinengadd+".labelTips").text = data.homemakingBaseCount+"个技能";
	});
});






